home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
038a
/
lyapunba.zip
/
LYAP.BAS
next >
Wrap
BASIC Source File
|
1991-09-21
|
2KB
|
72 lines
DEFINT I-N: DIM rxy(0 TO 1)
' set screen defaults
SCREEN 13: CLS
' set parameter ranges:
' niter = the number of iterations
' x1, x2 = limits of "b" range
' y1, y2 = limits of "a" range
' nx, ny = number of pixels
' xmax = maximum allowed size of iterate, to avoid overflows
x1 = -2: x2 = 4: y1 = -2: y2 = 4
nx = 320: ny = 200: niter = 100: xmax = 10
' start iteration with x = x0 = critical point
x0 = .5
' determine pixel steps
dx = (x2 - x1) / nx: dy = (y2 - y1) / ny
' start iterating
FOR j = 0 TO ny
' rxy(0) represents "b" in the "ab" periodic forcing
rxy(0) = dy * j + y1
FOR i = 0 TO nx
' rxy(1) represents "a" in the "ab" forcing
rxy(1) = dx * i + x1
x = x0
' iterate niter times to remove transients
FOR iter = 1 TO niter
' if l = 1, use "a"; if l = 0, use "b"
l = iter MOD 2
x = x * rxy(l) * (1 - x)
' color divergent points with color #1
IF ABS(x) > xmax THEN k = 1: GOTO colorpix
NEXT iter
' iterate niter times to compute exponent, stored in al
al = 0
FOR iter = 1 TO niter
l = iter MOD 2
x = x * rxy(l) * (1 - x)
IF ABS(x) > xmax THEN k = 1: GOTO colorpix
' d = ABS(the derivative of the function, with respect to x)
d = ABS(rxy(l) * (1 - 2 * x))
' avoid trying to find LOG(0)
IF d = 0 THEN d = 1E-10
' add LOG(d) to the running total for al;
' since I will scale al to determine a color mapping scheme, I
' don't need to divide d by LOG(2), as in the SA article
al = al + LOG(d)
' only color points with negative exponents (periodic orbits)
' change this IF-THEN-ELSE block to show positive exponents (chaotic)
IF al > 0# THEN
k = 0
ELSE
' at this point, use any scale factors you wish to get a nice
' distribution of colors
al = al / niter
k = ((-al * 100#) MOD 255) + 1
END IF
colorpix: PSET (i, j), k
NEXT i
NEXT j
' loop until a key is pressed
WHILE INKEY$ = "": WEND
endd: END
<<<>>>